home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / wc_DrawingA.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  6.9 KB  |  171 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         wc_DrawingA.c
  5. * RCS:          $Header: wc_DrawingA.c,v 1.3 91/03/14 03:14:34 mayer Exp $
  6. * Description:  XM_DRAWING_AREA_WIDGET_CLASS
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Fri Oct 27 22:22:38 1989
  9. * Modified:     Thu Oct  3 23:56:32 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: wc_DrawingA.c,v 1.3 91/03/14 03:14:34 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>
  45. #include <Xm/DrawingA.h>
  46. #include "winterp.h"
  47. #include "user_prefs.h"
  48. #include "xlisp/xlisp.h"
  49. #include "w_funtab.h"
  50.  
  51.  
  52. /******************************************************************************
  53.  * typedef struct
  54.  * {
  55.  *     int     reason;
  56.  *     XEvent  *event;
  57.  *     Window  window;
  58.  * } XmDrawingAreaCallbackStruct;
  59.  ******************************************************************************/
  60. static void Lexical_Bindings_For_XmDrawingAreaCallbackStruct(bindings_list, lexical_env, cd, o_widget)
  61.      LVAL bindings_list;    /* a list of symbols to which values from XmDrawingAreaCallbackStruct are bound */
  62.      LVAL lexical_env;        
  63.      XmDrawingAreaCallbackStruct* cd;
  64.      LVAL o_widget;        /* XLTYPE_WIDGETOBJ */
  65. {
  66.   extern LVAL s_CALLBACK_WIDGET, s_CALLBACK_REASON, s_CALLBACK_XEVENT, s_CALLBACK_WINDOW; /* w_callbacks.c */
  67.   extern LVAL Wcb_Get_Callback_Reason_Symbol();    /* w_callbacks.c */
  68.   register LVAL s_bindname;
  69.  
  70.   for ( ; consp(bindings_list); bindings_list = cdr(bindings_list)) {
  71.  
  72.     s_bindname = car(bindings_list);
  73.  
  74.     if (s_bindname == s_CALLBACK_WIDGET) {
  75.       xlpbind(s_bindname, o_widget, lexical_env);
  76.     }
  77.     else if (s_bindname == s_CALLBACK_REASON) {
  78.       xlpbind(s_bindname, Wcb_Get_Callback_Reason_Symbol(cd->reason), lexical_env);
  79.     }
  80.     else if (s_bindname == s_CALLBACK_XEVENT) {
  81.       xlpbind(s_bindname, (cd->event) ? cv_xevent(cd->event) : NIL, lexical_env);
  82.     }
  83.     else if (s_bindname == s_CALLBACK_WINDOW) {
  84.       xlpbind(s_bindname, (cd->window) ? cv_window(cd->window) : NIL, lexical_env);
  85.     }
  86.     else {
  87.       extern char temptext[];    /* from winterp.c */
  88.       sprintf(temptext,
  89.           "Unknown binding name in XmDrawingAreaCallbackStruct callback evaluator. Valid symbols are [%s %s %s %s].",
  90.           (char*) getstring(getpname(s_CALLBACK_WIDGET)),
  91.           (char*) getstring(getpname(s_CALLBACK_REASON)),
  92.           (char*) getstring(getpname(s_CALLBACK_XEVENT)),
  93.           (char*) getstring(getpname(s_CALLBACK_WINDOW)));
  94.       xlerror(temptext, s_bindname);
  95.     }
  96.   }
  97. }
  98.  
  99.  
  100. /******************************************************************************
  101.  * This is called indirectly via XtAddCallback() for callbacks returning
  102.  * an XmDrawingAreaCallbackStruct as call_data.
  103.  ******************************************************************************/
  104. static void XmDrawingAreaCallbackStruct_Callbackproc(widget, client_data, call_data)
  105.      Widget    widget;
  106.      XtPointer client_data;
  107.      XtPointer call_data;
  108. {
  109.   extern void Wcb_Meta_Callbackproc(); /* w_callbacks.c */
  110.  
  111.   Wcb_Meta_Callbackproc(client_data, call_data,
  112.             Lexical_Bindings_For_XmDrawingAreaCallbackStruct,
  113.             NULL);
  114. }
  115.  
  116.  
  117. /******************************************************************************
  118.  * Same as WIDGET_CLASS's :add_callback method except that this understands
  119.  * how to get values from the XmDrawingAreaCallbackStruct.
  120.  * Specifying one or more of the following symbols in the callback bindings 
  121.  * list will bind that symbol's value in the lexical environment of the callback:
  122.  * CALLBACK_WIDGET
  123.  * CALLBACK_REASON
  124.  * CALLBACK_XEVENT
  125.  * CALLBACK_WINDOW
  126.  ******************************************************************************/
  127. LVAL Xm_Drawing_Area_Widget_Class_Method_ADD_CALLBACK()
  128. {
  129.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  130.   return (Wcb_Meta_Method_Add_Callback(XmDrawingAreaCallbackStruct_Callbackproc, FALSE));
  131. }
  132.  
  133.  
  134. /******************************************************************************
  135.  * Same as WIDGET_CLASS's :set_callback method except that this understands
  136.  * how to get values from the XmDrawingAreaCallbackStruct.
  137.  * Specifying one or more of the following symbols in the callback bindings 
  138.  * list will bind that symbol's value in the lexical environment of the callback:
  139.  * CALLBACK_WIDGET
  140.  * CALLBACK_REASON
  141.  * CALLBACK_XEVENT
  142.  * CALLBACK_WINDOW
  143.  ******************************************************************************/
  144. LVAL Xm_Drawing_Area_Widget_Class_Method_SET_CALLBACK()
  145. {
  146.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  147.   return (Wcb_Meta_Method_Add_Callback(XmDrawingAreaCallbackStruct_Callbackproc, TRUE));
  148. }
  149.  
  150.  
  151. /******************************************************************************
  152.  *
  153.  ******************************************************************************/
  154. Wc_DrawingA_Init()
  155. {
  156.   LVAL o_XM_DRAWING_AREA_WIDGET_CLASS;
  157.   extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
  158.   extern      xladdmsg();    /* from xlobj.c */
  159.  
  160.   o_XM_DRAWING_AREA_WIDGET_CLASS =
  161.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_DRAWING_AREA_WIDGET_CLASS",
  162.                      xmDrawingAreaWidgetClass);
  163.   
  164.   xladdmsg(o_XM_DRAWING_AREA_WIDGET_CLASS, ":ADD_CALLBACK",
  165.            FTAB_Xm_Drawing_Area_Widget_Class_Method_ADD_CALLBACK);
  166.  
  167.   xladdmsg(o_XM_DRAWING_AREA_WIDGET_CLASS, ":SET_CALLBACK",
  168.            FTAB_Xm_Drawing_Area_Widget_Class_Method_SET_CALLBACK);
  169. }
  170.